package CI.aufgabe2.cip.mynodes;

import java.util.List;

import CI.aufgabe2.cip.SymbolTable;
import CI.aufgabe2.cip.base.AbstractDescr;

public class MyIdentListNode extends MyAbstractNode {

	private static final long serialVersionUID = 1L;

	private final List<MyIdNode> idents;

	public MyIdentListNode(List<MyIdNode> idents) {
		this.idents = idents;
	}

	public List<MyIdNode> getIdents() {
		return idents;
	}

	@Override
	public void print() {
		trace("IdentListNode ");
		if (idents != null)
			for (MyIdNode ident : idents) {
				if (ident != null)
					ident.print();
			}

		unindent();

	}

	public int getSize() {
		return idents.size();
	}

	public AbstractDescr compile(SymbolTable sym, AbstractDescr desc) {
		for (MyIdNode node : idents) {
			sym.declare(node.strval, desc);
		}
		return null; // schreibt nur in die Symboltabelle --> kein geeigneter
						// Ruechgabewert vorhanden
	}

	public AbstractDescr compileParams(SymbolTable table,
			AbstractDescr descriptor, boolean var) {
//		if (!var)
			for (MyIdNode node : idents) {
				node.setVar(var);
				table.declareParams(node.toString(), descriptor);
			}
		return null;
	}

}
